import javax.swing.*;
import java.awt.*;

public class HelloPanel extends JPanel {
    public HelloPanel() {
        JLabel text = new JLabel("按下任意键开始游戏", JLabel.CENTER);
        JLabel text2 = new JLabel("空格键暂停游戏", JLabel.CENTER);
        text.setFont(new Font(null, Font.BOLD, MainFrame.WIDTH / 14));
        text2.setFont(new Font(null, Font.BOLD, MainFrame.WIDTH / 16));

        JPanel rootPanel = new JPanel(new GridLayout(4, 0));
        //rootPanel.setPreferredSize(new Dimension(0, 50));
        JPanel nullPanel = new JPanel();//空图层
        nullPanel.setOpaque(false);

        rootPanel.add(nullPanel);
        rootPanel.add(text);
        rootPanel.add(text2);

        setLayout(new BorderLayout());
        setBounds(0, 0, MainFrame.WIDTH, MainFrame.WIDTH);
        rootPanel.setBackground(Color.GRAY);
        //rootPanel.setOpaque(false);

        //setOpaque(true);
        //setBackground(Color.RED);
        add(rootPanel);
    }

}
